<script setup lang="ts">
import {storageLocal} from "@pureadmin/utils";
import {usePermissionStoreHook} from "@/store/modules/permission";
import {initRouter} from "@/router/utils";
import {ref} from "vue";
import {hanjunTestStoreHook} from "@/store/modules/hanjuntest";


const username = ref(hanjunTestStoreHook()?.username);
const password = ref(hanjunTestStoreHook()?.username);

function login() {
  // alert("Login success!");
  hanjunTestStoreHook()
    .loginByUsername2({username: username.value, password: password.value})
    .then(res => {
      // debugger
      console.log("api resolve(res): Login success!");
      if (res.success) {

        storageLocal().removeItem("async-routes");
        usePermissionStoreHook().clearAllCachePage();
        // initRouter();
      }
    });
}
</script>

<template>
  <div class="flex justify-center items-center h-screen">
<!--  编写一个用于登录的表单提交  -->
    <form @submit.prevent="login">
      <input v-model="username" type="text" placeholder="Username" />
      <br />
      <input v-model="password" type="password" placeholder="Password" /> <br />
      <button type="submit">Login</button>
    </form>

  </div>
</template>

<style scoped>
</style>
